package com.shujia.wyh.day08;

import java.util.Scanner;

/*
    举例：键盘录入”abc”		输出结果：”cba”
 */
public class StringTest1 {
    public static void main(String[] args) {
        //创建键盘录入对象
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入一个字符串：");
        String line = sc.next();
        System.out.println(line);

        char[] chars = line.toCharArray();
        for (int start = 0, end = chars.length - 1; start < end; start++, end--) {
            char tmp = chars[start];
            chars[start] = chars[end];
            chars[end] = tmp;
        }

        String s = new String(chars);
        System.out.println("逆序后：" + s);
    }
}
